<script language="javascript" type="text/javascript" src="p_igreja/valida_form.js"></script>
<?php 

	$id = $_GET['i'];
	$resul = mysql_query("SELECT agenda_eventos.id, agenda_eventos.evento, agenda_eventos.dtevento, agenda_eventos.data, agenda_eventos.hora, agenda_eventos.descricao, agenda_eventos.local, agenda_eventos.user_id, usuarios.id, usuarios.username FROM agenda_eventos, usuarios
			WHERE agenda_eventos.user_id = usuarios.id AND agenda_eventos.id = $id");
	$agenda = mysql_fetch_array($resul);

?>
<div class="form bg-warning">
	<div class="row">
		<div class="col-md-12">
			<div class="page-header">
				<h2>Editar dados do Evento</h2>
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-md-3">
			<?php include "actions-agenda.php"?>
		</div><!-- end col md 3 -->
		<div class="col-md-9">
		<!-- HEAD DE FORMULÃ�RIO -->
		<div class="panel panel-default">
			<div class="panel-heading"><h5>Formulário de edição de Cadastro de igreja</h5></div>
			<div class="panel-body">
			<!-- FORMULÃ�RIO -->
			<form  method="post" name="form1" action="p_agenda/editar.php" enctype="multipart/form-data">
				<div class="row">
					<div class="col-md-12 form-group"><h6>(<span class="text-danger">*</span>) Campos de preenchimento obrigatório.</h6></div>
				</div>
				<input type="hidden" name="idagenda" value="<?php echo $agenda['id'];?>">
				<input type="hidden" name="iduser" value="<?php echo $agenda['user_id'];?>">
				
				<div class="row">
					<div class="form-group col-md-9">
						<label for="evento">Evento (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" name="evento" id="evento" value="<?php echo $agenda['evento'] ?>">
					</div>
				</div>
				
				<div class="row">	
					<div class="form-group col-md-7">
							<label for="username">Autor do Cadastro (<span class="text-danger">*</span>)</label>
	    					<select name="username" id="username" class="form-control">
			          			<option value='selecione'>Selecione...</option>
			          			<?php
									$query = mysql_query("SELECT id, username, membro_id FROM usuarios");
									while($lista = mysql_fetch_array($query)) {
										if($lista['id'] == $agenda['user_id']){?>
												<option value="<?php echo $lista['id']; ?>" selected><?php echo $lista['username']; ?></option>
											<?php }else{?>
											<option value="<?php echo $lista['id']; ?>"><?php echo $lista['username']; ?></option>
									<?php }}?> 
			          		</select>
					</div>
				</div>
				
				<div class="row">
					<div class="form-group col-md-3">
						<label for="dtevento">Data (<span class="text-danger">*</span>) D-M-AAAA</label>
    					<input type="text" class="form-control" name="dtevento" id="dtevento" value="<?php echo $agenda['dtevento'] ?>">
					</div>
				</div>

				<div class="row">
					<div class="form-group col-md-4">
						<label for="hora">Horário (<span class="text-danger">*</span>) HH:MM</label>
    					<input type="text" class="form-control" name="hora" id="hora" value="<?php echo $agenda['hora'] ?>">
					</div>				
				</div>
				
				<div class="row">
					<div class="form-group col-md-8">
						<label for="local">Local (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" name="local" id="local" value="<?php echo $agenda['local'] ?>">
					</div>
				</div>
				
				<div class="row">
					<div class="form-group col-md-8">
						<label for="descricao">Descrição (<span class="text-danger">*</span>)</label>
    					<input type="text" class="form-control" name="descricao" id="descricao" value="<?php echo $agenda['descricao'] ?>">
					</div>
				</div>
				
				<br>
				<div class="row">
					<div class="form-group col-md-2">
						<input type="submit" value="Salvar" class="btn btn-default" name="enviar" onclick="return valida()" >
					</div>
				</div>
			</form>
			</div>
		</div>

		</div><!-- end col md 12 -->
	</div><!-- end row -->
</div>
			